﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Text;

public partial class ybqy_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox1.ReadOnly = false;
        if (TextBox1.Text=="")
        {
           Response.Redirect("1-1.aspx"); 
        }
        string jindu = "";
        string weidu = "";
        string fen = "";
        string du = "";
        
        TextBox1.Text = (float.Parse(TextBox1.Text) - 0.002937).ToString();
        TextBox2.Text = (float.Parse(TextBox2.Text) - 0.01108).ToString();
        du=(float.Parse( "0."+TextBox1.Text.Substring(4, TextBox1.Text.Length-4))*60).ToString();//带小数点
        fen=du.Substring(0,du.IndexOf("."));
        if (fen.Length == 1) { fen = "0" + fen; }

        du = (float.Parse( du.Substring(du.IndexOf("."), du.Length - du.IndexOf(".")))*60).ToString();

        du = du.Substring(0, du.IndexOf("."));
        if (du.Length == 1) { du = "0" + du; }
        jindu = TextBox1.Text.Substring(0, 3) + fen+du;

        du = (float.Parse("0." + TextBox2.Text.Substring(3, TextBox2.Text.Length - 3)) * 60).ToString();//带小数点
        fen = du.Substring(0, du.IndexOf("."));
        if (fen.Length == 1) { fen = "0" + fen; }

        du = (float.Parse(du.Substring(du.IndexOf("."), du.Length - du.IndexOf("."))) * 60).ToString();

        du = du.Substring(0, du.IndexOf("."));
        if (du.Length == 1) { du = "0" + du; }
        weidu = TextBox2.Text.Substring(0, 2) + fen + du;

        SqlConnection sqlcon = new SqlConnection();
        sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon.Open();

        SqlCommand sqlcmd = new SqlCommand("update  a01101 set XAIS='" + jindu + "',YAIS='" + weidu + "' where ShenBaoNianDu='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"], sqlcon);
        sqlcmd.ExecuteNonQuery();
        Response.Redirect("1-1.aspx");
    }
}